package com.example.order.client;

import com.example.order.dataObject.ProductInfoOutput;
import com.example.order.dto.CartDTO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import java.util.List;

@Component
@FeignClient(name = "product",fallback = ProductClient.ProductClientFallBack.class)//填入对应服务名
public interface ProductClient {



    @RequestMapping("/msg")
    String proDuctMag();

    /**
     * 根据商品id查询出对应商品
     * @param list
     * @return
     */
    @RequestMapping(value = "/product/listForOrder",method = RequestMethod.POST)
    List<ProductInfoOutput> listForOrder(@RequestBody List<String> list);

    /**
     * 去库存
     * @param list
     */
    @RequestMapping(value = "/product/decreaseStock",method = RequestMethod.POST )
    void decreaseStock(@RequestBody List<CartDTO> list);


    @Component
    static class ProductClientFallBack implements ProductClient{

        @Override
        public String proDuctMag() {
            return null;
        }

        @Override
        public List<ProductInfoOutput> listForOrder(List<String> list) {
            return null;
        }

        @Override
        public void decreaseStock(List<CartDTO> list) {

        }
    }
}
